/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.*;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class LineTrackerAZ extends IterativeRobot {
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    DigitalInput LeftLineTracker;
    DigitalInput MiddleLineTracker;
    DigitalInput RightLineTracker;
    int xint =0;
    public void robotInit() {
        LeftLineTracker = new DigitalInput(1);
        MiddleLineTracker = new DigitalInput(3);
        RightLineTracker = new DigitalInput(5);
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {

    }

    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
     byte leftLT = LeftLineTracker.get() ? (byte)1:(byte)0;
     byte middleLT = MiddleLineTracker.get() ? (byte)0:(byte)1;
     byte rightLT = RightLineTracker.get() ? (byte)1:(byte)0;
     byte binaryValue = (byte)(leftLT*100 + middleLT*10 + rightLT);
     System.out.print(++xint + " ");
     switch (binaryValue){
         case 010:
             System.out.println("The middle tracker has found the line");
             break;
         case 100:
             System.out.println("The left tracker has found the line");
             break;
         case 001:
             System.out.println("The right tracker has found the line");
             break;
         case 000:
             System.out.println("No line is found");
             break;
         case 111:
             System.out.println("All three trackers have found the line");
             break;
         case 101:
             System.out.println("The outside trackers have found the line");
             break;
         case 110:
             System.out.println("The left and the mid trackers have found the line");
             break;
         case 011:
             System.out.println("Middle and right trackers have found the line");
             break;
     }
    }
    
}